package cn.kgm.makeGodV2.ruleEngine;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Version 1.8
 * @Author: Kappi
 * @Date: 2025-9-24 10:31
 * @Description: cn.kgm.makeGodV2.ruleEngine.RuleResult
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class RuleResult<T> {
    private boolean success;
    private String message;
    private T data;
    private String errorCode;


    // 构造方法
    public static <T> RuleResult<T> success(T data) {
        return new RuleResult<>(true, "成功", data, null);
    }

    public static <T> RuleResult<T> success(String message, T data) {
        return new RuleResult<>(true, message, data, null);
    }

    public static <T> RuleResult<T> fail(String message) {
        return new RuleResult<>(false, message, null, "RULE_ERROR");
    }

    public static <T> RuleResult<T> fail(String errorCode, String message) {
        return new RuleResult<>(false, message, null, errorCode);
    }
}
